public class StringComparePerformance {
    public static void main(String args[]){
        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++){
            String str1 = "Runoob";
            String str2 = "Runoob";
        }
        long endTime = System.currentTimeMillis();
        System.out.println("通过String关键词创建字符串"+":"+(endTime-startTime)+"毫秒");
        long startTime1 = System.currentTimeMillis();
        for (int i = 0; i < 50000; i++){
            String str1 = new String("Runoob");
            String str2 = new String("Runoob");
        }
        long endTime1 = System.currentTimeMillis();
        System.out.println("通过new关键字创建字符串"+":"+(endTime1-startTime1)+"毫秒");
    }
}
